import 'package:flutter/material.dart';
import 'package:flutter_kit_dsp/flutter_kit_dsp.dart';
import 'package:flutter_kit_plus/flutter_kit.dart';

import '../../commont/button.dart';
import '../../tool/assets.dart';

class OutputDbItem extends StatelessWidget {
  ChannelModel model;
  void Function(double) onChange;
  void Function(String) onClick;
  void Function(double) onChangedForSend;

  OutputDbItem(
      {super.key, required this.model, required this.onChange, required this.onChangedForSend, required this.onClick});

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      width: 30,
      child: Column(
        children: [
          ///ch1
          Expanded(
            child: Container(
                alignment: Alignment.bottomCenter,
                child: Text(model.name, style: const TextStyle(color: Colors.white))),
          ),

          ///间隙
          const SizedBox(height: 5),

          ///mute按钮
          Flexible(
            child: kMyIconButton(
              name: model.mute ? assets.mute_off : assets.mute_on,
              onClick: (p0) => onClick('MUTE'),
            ),
          ),

          ///间隙
          const SizedBox(height: 5),

          ///滑动块
          Flexible(
            flex: 10,
            child: kSlider(
              dirction: Axis.horizontal,
              value: model.db,
              min: model.min_db,
              max: model.max_db,
              onChanged: (p0) => onChange(p0),
              onChangedForSend: (p0) => onChangedForSend(p0),
            ),
          ),

          ///间隙
          const SizedBox(height: 5),

          ///dB
          Flexible(child: kMyTextButton(name: '${model.db.floor()}')),

          const Flexible(child: SizedBox(height: 5)),

          ///Phase
          Flexible(
            child: kMyTextButton(name: model.phase ? '0°' : '180°', onClick: (p0) => onClick('PHASE')),
          ),
        ],
      ),
    );
  }
}
